<?php

namespace App\Repositories\Eloquent\Admin;

use App\Repositories\Eloquent\BaseModel;
use EasySwoole\ORM\AbstractModel;


class AdminModel extends AbstractModel
{
    use BaseModel;
    protected $tableName = 'k_admin';
    protected $connectionName = 'wr';
    protected $autoTimeStamp = true;
    protected $createTime = 'add_time';
    protected $updateTime = 'update_time';


    public function getList(array $where = [],$pageNum = PAGE_SIZE){
        $datas = $this->create()->alias('a')
            ->field('a.id,a.name,a.account,a.status,c.name as role_name,a.add_time,a.update_time')
            ->join('k_admin_role_party b','b.id_admin = a.id','LEFT')
            ->join('k_admin_role c','c.id = b.id_role','LEFT')
            ->where($where)
            ->order('a.add_time','desc')
            ->_page($pageNum);
        return $datas;
    }

    public function getItemByAccount(string $account = ''){
        return $this->create()->get(['account'=> $account]);
    }




}